Chris Pollett > Old Classes >
CS152

( Print View )

Student Corner:
  [Grades Sec1]

  [Submit Sec1]

  [Class Sign Up Sec1]

  [
Lecture Notes]
  [Discussion Board]

Course Info:
  [Texts & Links]
  [Topics/Outcomes]
  [Outcomes Matrix]
  [Grading]
  [HW/Quiz Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Additional Policies]
  [Announcements]

HWs and Quizzes:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]  [Quizzes]

Practice Exams:
  [Mid]  [Final]

                           












HW#4 --- last modified February 28 2019 22:25:47..

Solution set.

Due date: Apr 22

Files to be submitted:
  Hw4.zip

Purpose: To gain experience writing non-trivial functional programs. To get more practice writing parsers.

Related Course Outcomes:

The main course outcomes covered by this assignment are:

LO8 -- Write interpreters for simple languages that involve arithmetic expressions, bindings of values to names, and function calls.

LO11 -- Produce programs in a functional programming language in excess of 200 lines of code.

Specification:

Hw4 due date was extended to April 24. 1Pt Bonus was given April 22nd submissions. For this homework you will make a Scheme program which reads in a spreadsheet file in a tabbed format, evaluates the file, and prints the result to the screen. Your Scheme program should be in the file SpreadVal.scm which the grader will load into Dr. Scheme. The grader will set the Dr. Scheme Language to be "Pretty Big" and type (scheme-val "some_file_name") to run your code. You should provide a few sample spreadsheets in along with SpreadVal.scm in the file Hw4.zip which you will submit. The grader will also use some additional tests files besides the ones you submit. Your code should be written according to the following Scheme Coding Guidelines.

For this assignment a spreadsheet file consists of a sequence of rows, where each row is made up of cells, and each cell is separated by a tab. Rows are delimited by newlines. We assume all rows in our files have the same number of cells. We name cells by the column and row in which it appears. The format of cell names is [A-Z][A-Z][0-9][0-9][0-9] and names are ordered lexicographically. So the first cell is AA000. Cells are allowed to contain expressions. The set of expressions is the smallest set containing (1) the set of numbers, (2) the set of all cell names, and containing, whenever expr1 and expr2 are previously defined expressions, (3) expr1 padded on either side by spaces, (4) (expr1+expr2), (5) (expr1*expr2), (6) (-expr1), and (7) (expr/expr). A given cell is only allowed to contain expressions involving cell names which either involve a strictly smaller row component, or which involve a strictly smaller column and the same row. So for example, the cell AB500 is allowed to contain the expression ((AA500 + ZZ499) * 10). It is not allowed to contain the expression ZZ500 or even AB500. A number has the format (-)?(([1-9][0-9]*(\.)?[0-9]*) | ((0)?\.[0-9]+)). We will assume that numbers can be held by Scheme's number type for evaluation purposes. i.e., you don't have to write your own code to handle arbitrarily large numbers that might not fit in Scheme's number type. An example test file might look like:

1	(AA000 + (- 3.5)) 	5.2
(AB000 + AC000)	22	10
(AA001 * AC001)	22	1.0

On such an input your program should evaluate each cell and spit out the correct output table. To evaluate an expression, numbers evaluate to themselves, cell names evaluate to the value that that the cell evaluated to, and otherwise we evaluate according to the usual rules for +,*,-, and /. For the above table we would get the following printed to the screen:

1	-2.5	5.2
2.7	22	10
27	22	1.0

In addition to the above, your code should be written using the message passing method of doing OO in Scheme. You should also use continuation somewhere in your code constructively.

Point Breakdown

Scheme Coding Guidelines followed 1pt
Program can read in files involving only spreadsheets with numbers and generates the correct result 1pt
Program works on files with expressions that involve only numbers or cell names but not more complicated expressions 2pts
Program works on files with expressions that involving expressions based on cell names which refer to numbers 2pts
Program works on files with the full class of expressions described above 2pts
Code written using message passing, continuation are used constructively. (1 pt each) 2pts
Total10pts